<?php
/**
 * 概要描述：
 * @author: 救火队队长
 * @since: 2020-03-10 9:54
 */
namespace app\common\exception;

use think\exception\Handle;
use think\exception\HttpException;
use think\exception\ValidateException;
use think\Response;
use Throwable;

class Http extends Handle
{
    public function __call($name, $arguments)
    {
        return show(config("status.error"),'找不到该方法');
    }

    public function render($request, Throwable $e): Response
    {
        // 请求异常
        //return $e->getMessage();

        if ($request->isAjax()) {
            $result = [
                'message' => $e->getMessage(),
                'code' => $e->getCode(),
            ];

            return json($result, 500);
        }else{
            return parent::render($request, $e);
        }

        //return response($e->getMessage(), $e->getCode());

        //dump($e);
       // die();

    }

}